<html>
<head>
<script src="base64.js" type="text/javascript"></script>
<title>base64 encode speeed</title>
</head>
<body>
<pre>
<script>
var t0 = Date.now();
for (var i = 0; i < 10000; ++i) {
base64.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/');
}
document.writeln("JS encode: " + (Date.now() - t0));

if (window.btoa) {
var t0 = Date.now();
for (var i = 0; i < 10000; ++i) {
window.btoa('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/');
}
document.writeln("Native encode: " + (Date.now() - t0));
}


var x = base64.encode('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/');

var t0 = Date.now();
for (var i = 0; i < 10000; ++i) {
base64.decode(x);
}
document.writeln("JS decode: " + (Date.now() - t0));


if (window.atob) {
var t0 = Date.now();
for (var i = 0; i < 10000; ++i) {
window.atob(x);
}
document.writeln("Native decode: " + (Date.now() - t0));
}
</script>
</pre>
</body>
</html>
